package com.wx.spring.utils;

import com.wx.spring.ioc.rules.RulesEnumTemplate;

import java.util.Objects;

/**
 * @author wx
 * @Description: 枚举工具类
 * @date 2019/1/8 000815:10
 */
public class EnumsUtils {
    private EnumsUtils(){
        throw new RuntimeException("工具类禁止实例化");
    }


    /**
     * @description: 根据类型获取规则枚举
     * @author: wx
     * @date: 2019/1/8 0008
     * @param enumClass
     * @param type
     * @return: T
     */
    public static <T extends RulesEnumTemplate> T getRulesEnum(Class<T> enumClass,String type){
        if (MyStringUtils.isBlank(type)){
            return null;
        }
        for (T t : enumClass.getEnumConstants()) {
            if (Objects.equals(type,t.getType())){
                return t;
            }
        }
        return null;
    }
}
